<!-- 引入模板文件 -->
<!-- 注意：引用的是绝对路径 -->

<!-- 页面标题 -->
<block name="title"><title>Index/login</title></block>

<!-- 添加该页面对应需要的css文件 -->
<block name="link">
  <link rel="shortcut icon" src="../../../../../favicon.ico" />
  <link rel="stylesheet" type="text/css" href="../../../../../Public/source/layui/css/layui.css">
  <link rel="stylesheet" type="text/css" href="../../../../../Public/source/css/css3.css">
  <style type="text/css">
   .form > .layui-form-label{
    position: absolute;
    right: 100px;
   }
   #sub{
    position: relative;
    padding-left: -300px;
    padding-top: -50px;
   }


    
  </style>
   
</block>


<!-- 右下侧的主体内容 主要内容在此处写 -->
<block name="content">
        <div class="layui-body">
            <div class="form">
               <!-- 代码从此次开始写，外层两个div不建议删除 -->
               <div class="layui-form">
                   <label class="layui-form-label">培训编号</label>
                    <div class="layui-input-inline">
                      <input type="text" id="no" autocomplete="off" class="layui-input">
                    </div>
               </div>
               <div class="layui-form">
                   <label class="layui-form-label">培训主题</label>
                    <div class="layui-input-inline">
                      <input type="text"  id="title" autocomplete="off" class="layui-input">
                    </div>
               </div>
               <div class="layui-form">
                   <label class="layui-form-label">培训类型</label>
                    <div class="layui-input-inline">
                      <input type="text"  id="type" autocomplete="off" class="layui-input">
                    </div>
               </div>

               <div class="layui-form">
                 <label class="layui-form-label">日期</label>
                  <div class="layui-input-inline">
                    <input class="layui-input" id="date" type="text" placeholder="yyyy-MM-dd">
                  </div>
               </div>


               <div class="layui-form-item1">
                   <label class="layui-form-label">培训人员</label>
                    <div class="layui-input-inline">
                       <textarea id="participant" required lay-verify="required" placeholder="请输入" class="layui-textarea"></textarea>
                    </div>
               </div>

               <div class="layui-form-item2">
                   <label class="layui-form-label">培训大概内容</label>
                    <div class="layui-input-inline">
                       <textarea id="content" required lay-verify="required" placeholder="请输入" class="layui-textarea"></textarea>
                    </div>
               </div>

               <div class="layui-form-item3">
                   <label class="layui-form-label">培训内容记录</label>
                        <!-- <button type="button" class="layui-btn" id="test2" >
                          <i class="layui-icon">&#xe67c;</i>上传图片
                        </button> -->

                        <button type="button" class="layui-btn" id="test3" >
                          <i class="layui-icon">&#xe67c;</i>上传文件
                        </button>
               </div>
              <input type="hidden" id="savename">
               <input type="hidden" id="initname">
               <div class="layui-btn-group">
                  <button id="sub" class="layui-btn">保存</button>
               </div>

               


                
              
        </div>
    </div>
</block>  





<!-- 引入或写js代码 -->
<block name="js">
  <script src="../../../../../Public/source/layui/layui.js"></script>
  <!-- <script src="../../Application/build/layui.js"></script> -->
  <script>
  //JavaScript代码区域
  layui.use('element', function(){
    var element = layui.element;
    
  });
</script>

<!-- <script src="/static/build/layui.js"></script> -->
<script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  //执行一个laydate实例
  laydate.render({
    elem: '#test1' //指定元素
  });
});
</script>


<!-- 上传图片 -->
<script>  
layui.use('upload', function(){
  var upload = layui.upload;
   
  //执行实例
  var uploadInst = upload.render({
    elem: '#test2' //绑定元素
    ,url: '../../../Public/Train' //上传接口
    ,done: function(res){
      //上传完毕回调
    }
    ,error: function(){
      //请求异常回调
    }
  });
});
</script>

<!-- 上传文件 -->
<script>  
layui.use('upload', function(){
  var upload = layui.upload;
   
  //执行实例
  var uploadInst = upload.render({
    elem: '#test3' //绑定元素
    ,url: '__URL__/upfile' //上传接口
    ,accept:'file'
    ,done: function(res){
      $('#initname').val(res[0]);
      $('#savename').val(res[1]);
    }
    ,error: function(){
      //请求异常回调
      alert('文件上传失败');
    }
  });
});
</script>

<script type="text/javascript" src="../../../../../Public/source/jquery-3.2.1.js"></script>
<script type="text/javascript"> 
$.ajax({
  async:true,
  type:'post',
  url:'__URL__/showmore1/id/{$info2.id}',
  data:{},
  success:function(data)
  {
    $('#no').val(data.no);
    $('#date').val(data.date);
    $('#participant').val(data.participant);
    $('#content').val(data.content);
    $('#title').val(data.title);
    $('#type').val(data.type);
  },
  error:function(data){
    alert('error');
  }
}
)
$(function(){
$('#sub').click(function(){
     var no1=$('#no').val();
     var date1 = $('#date').val();
     var host1=$('#host').val();
     var participant1=$('#participant').val();
     var content1=$('#content').val();
     var title1=$('#title').val();
     var type1=$('#type').val();
    var initname1=$('#initname').val();
    var savename1=$('#savename').val();
     $.ajax({
      async:false,
       type:'post',
       dataType:'json',
       url:'__URL__/xiugai1/id/{$info2.id}',//后台提供接口
       data:{
         no:no1, 
         date:date1,
         host:host1,
         participant:participant1,
         content:content1,
         title:title1,
         type:type1,
         savename:savename1,
         initname:initname1,
       }, 
       success:function(data)
       {
           alert('修改成功');
       },
       error:function(data)
       {
        alert('修改失败')
       }
     });
   });
 })
</script>
</block>